//
//  HealthCenterViewController.m
//  SpiritWalk
//
//  Created by dllo on 16/3/12.
//  Copyright © 2016年 王鑫. All rights reserved.
//

#import "HealthCenterViewController.h"
//三方
#import "SZCalendarPicker.h"    //日历
#import "SNChart.h"                   //柱状图
#import "VAProgressCircle.h"    //进度条
#import "VMButtonCircleFun.h"  //按钮
//codata
#import "CoreDataManager.h"
#import "Health.h"
#import "TimeOfDay.h"
//VC
#import "WYWRunMapViewController.h"
#import "AddViewController.h"
#import "WYWWeatherView.h"
#import "Tool.h"

@interface HealthCenterViewController () <SNChartDataSource,VAProgressCircleDelegate>
//进度条
@property int circleProgress;
@property (strong, nonatomic) VAProgressCircle *circleChart;
@property (strong, nonatomic) NSTimer *randomTimer;

@property(nonatomic,retain)CoreDataManager * manager;
@property(nonatomic,retain)UIView * topView;
@property(nonatomic,strong)UILabel *calendarLabel;
@property(nonatomic,strong) SZCalendarPicker *calendarPicker;
@property(nonatomic,strong) UILabel * dateLabel;

@property(nonatomic,assign)NSInteger  kcal;
@property(nonatomic,assign)CGFloat  kil;
@property(nonatomic,assign)NSInteger stepCount;
@property(nonatomic,assign)NSInteger time;
@property(nonatomic,retain) SNChart * chart;
@property(nonatomic,retain)UICountingLabel * stepNumberCountingLabel;
@property(nonatomic,retain)UICountingLabel * dakaCountingLabel;
@property(nonatomic,retain)UICountingLabel * timeCountingLabel;
@property(nonatomic,retain)UICountingLabel * gongliCountingLabel;
@property(nonatomic,retain)NSArray * stepCountArr;
//天气
@property(nonatomic,retain)UIView * weatherView;
@property(nonatomic,retain)NSMutableDictionary * weatherDic;
@property(nonatomic,retain)UIImageView *  weatherIcon_ImageVIew;   //图标
@property(nonatomic,retain)UILabel *  weatherTmpTxt_Label;   // 天气温度
//@property(nonatomic,retain)UILabel *  weatherTxt_Label;  //天气类型
@property(nonatomic,retain)UILabel *  weatherAqi_Label;     //空气质量
@property(nonatomic,retain)UILabel *  weatherQlty_Label;    //空气类型
@end

@implementation HealthCenterViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent=NO;
    self.tabBarController.tabBar.translucent=NO;
    //self.view.backgroundColor=[UIColor colorWithRed:40/255.0 green:45/255.0 blue:50/255.0 alpha:1];
    self.view.backgroundColor=[UIColor whiteColor];
     //self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"iconfont-jiahao.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ] style:UIBarButtonItemStylePlain target:self action:@selector(add:)];
    [self createData:nil];
    [self createWeatherData];
    [self createCalendar];
    [self createTopView];
    [self createLineProgressView];
    [self createPhotoAndMap];
    [self createSNchart];
    [self createWeather];
 
   
    }
-(void)createWeatherData{
    //--------------------天气--------------------------------
    self.weatherDic=[NSMutableDictionary dictionary];
    NSString *weatherUrlStr=@"https://api.heweather.com/x3/weather?cityid=CN101070201&key=68b4fe4fb1ae434d935bb8f25b7acf64";
    [Tool GET:weatherUrlStr  black:^(id data) {
        NSDictionary * dataDic=data[@"HeWeather data service 3.0"][0];
        NSLog(@"===============tianqi======%@",dataDic[@"now"][@"tmp"]);
          [self.weatherDic setObject:dataDic[@"now"][@"tmp"] forKey:@"tmp"]; //温度             24°
          [self.weatherDic setObject:dataDic[@"now"][@"hum"] forKey:@"hum"]; //湿度    25%
        [self.weatherDic setObject:dataDic[@"now"][@"pres"] forKey:@"pres"]; //气压    1010hPa
          [self.weatherDic setObject:dataDic[@"now"][@"cond"][@"txt"] forKey:@"txt"]; //天气状况         晴
          [self.weatherDic setObject:dataDic[@"now"][@"wind"][@"dir"] forKey:@"dir"]; //风向  东南风
          [self.weatherDic setObject:dataDic[@"now"][@"wind"][@"sc"] forKey:@"sc"]; //风力 3-4级
      //  [self.weatherDic setObject:dataDic[@"now"][@"cond"][@"code"] forKey:@"code"]; //天气状况图片id;  100
         [self.weatherDic setObject:dataDic[@"aqi"][@"city"][@"pm25"] forKey:@"pm25"];  //pm25
         [self.weatherDic setObject:dataDic[@"aqi"][@"city"][@"pm10"] forKey:@"pm10"];  //pm25
         [self.weatherDic setObject:dataDic[@"aqi"][@"city"][@"qlty"] forKey:@"qlty"];  //空气质量类别  良
           [self.weatherDic setObject:dataDic[@"suggestion"][@"comf"][@"txt"] forKey:@"comf"];  //穿衣推荐
        
        
        self.weatherAqi_Label.text=[NSString stringWithFormat:@"pm2.5:%@",dataDic[@"aqi"][@"city"][@"pm25"]];
        self.weatherTmpTxt_Label.text=[NSString stringWithFormat:@"%@°%@",dataDic[@"now"][@"tmp"],dataDic[@"now"][@"cond"][@"txt"]];
        NSString * codeUrlStr=@"https://api.heweather.com/x3/condition?search=allcond&key=68b4fe4fb1ae434d935bb8f25b7acf64";
        [Tool GET:codeUrlStr black:^(id data) {
            for ( NSDictionary * tempDic in data[@"cond_info"]) {
                if ([tempDic[@"code"] isEqualToString:dataDic[@"now"][@"cond"][@"code"]]) {
                 //   [self.weatherDic setObject:tempDic[@"icon"] forKey:@"icon"];   //天气状况图片地址
                    [self.weatherIcon_ImageVIew sd_setImageWithURL:[NSURL URLWithString:tempDic[@"icon"]]];
                    break;
                }
            }
            NSLog(@"%@",self.weatherDic);
        }];
        
    }];

}
-(void)createData :(NSString*)toDate{
    self.manager=[CoreDataManager manager];
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Health" inManagedObjectContext:self.manager.managedObjectContext];
    [fetchRequest setEntity:entity];
    NSDate *date = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"YYYY-MM-dd"];
        NSString *dateString = [dateFormatter stringFromDate:date];
    if (toDate) {
        dateString=toDate;
    }
     NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date=%@ ", dateString];
      [fetchRequest setPredicate:predicate];
    NSError *error = nil;
    NSArray *fetchedObjects = [self.manager.managedObjectContext executeFetchRequest:fetchRequest error:&error];
    if (fetchedObjects == nil) {
        NSLog(@"---空的");
    }
    NSLog(@"---不空的");
        for (Health * healt in fetchedObjects) {
            self.kcal=[healt.kcal integerValue];
            self.kil=[healt.kil floatValue];
            self.stepCount=[healt.stepCount integerValue];
            self.time=[healt.time integerValue];
            
           // NSLog(@"date=%@ step=%@ floor=%@  kil=%@  time=%@  kcal=%@" ,healt.date,healt.stepCount ,healt.floor,healt.kil,healt.time,healt.kcal);
        }
    //-------------------------------时间段数据
     NSFetchRequest *fetchRequest2 = [[NSFetchRequest alloc] init];
    entity = [NSEntityDescription entityForName:@"TimeOfDay" inManagedObjectContext:self.manager.managedObjectContext];
    [fetchRequest2 setEntity:entity];
    predicate = [NSPredicate predicateWithFormat:@"date=%@", dateString];
   // NSLog(@"--------------------%@",dateString);
    [fetchRequest2 setPredicate:predicate];
    NSArray *fetchedObjects2 = [self.manager.managedObjectContext executeFetchRequest:fetchRequest2 error:&error];
    if (fetchedObjects2 == nil) {}
        for (TimeOfDay * day in fetchedObjects2) {
           // NSLog(@"==============%@============%@",day.date,day.stepCount);
            self.stepCountArr=[day.stepCount componentsSeparatedByString:@","];
        }
   
    
}
-(void)createWeather{
    UIView * weatherView=[UIView new];
    [self.view addSubview:weatherView];
    UITapGestureRecognizer * weatherTap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(weatherAction:)];
    [weatherView addGestureRecognizer:weatherTap];
    [weatherView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 50));
        make.top.mas_equalTo(self.topView.mas_bottom).offset(20);
        //make.centerX.mas_equalTo(self.circleChart);
    }];
  //  weatherView.backgroundColor=[UIColor redColor];
    self.weatherIcon_ImageVIew=[UIImageView new];
    [weatherView addSubview:self.weatherIcon_ImageVIew];
    [self.weatherIcon_ImageVIew mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.and.bottom.equalTo(weatherView);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    self.weatherTmpTxt_Label=[UILabel new];
    self.weatherTmpTxt_Label.font=[UIFont systemFontOfSize:13];
    [weatherView addSubview:self.weatherTmpTxt_Label];
    [self.weatherTmpTxt_Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(100, 20));
        make.top.mas_equalTo(weatherView).offset(5);
        make.left.mas_equalTo(self.weatherIcon_ImageVIew.mas_right);
    }];
    self.weatherAqi_Label=[UILabel new];
    self.weatherAqi_Label.font=[UIFont systemFontOfSize:10];
    [weatherView addSubview:self.weatherAqi_Label];
    [self.weatherAqi_Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(50, 25));
        make.top.mas_equalTo(self.weatherTmpTxt_Label.mas_bottom);
        make.left.mas_equalTo(self.weatherIcon_ImageVIew.mas_right);
    }];
  //  self.weatherIcon_ImageVIew.backgroundColor=[UIColor blackColor];
}
-(void)weatherAction:(UITapGestureRecognizer*)tap{
    _weatherView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    WYWWeatherView * wView=[[WYWWeatherView alloc] initWithFrame:CGRectMake(80, 100, WIDTH-160, HEIGHT-100)];
    [_weatherView addSubview:wView];
    wView.tmpLabel.text=[NSString stringWithFormat:@"%@°",self.weatherDic[@"tmp"]];
    wView.txtLabel.text=self.weatherDic[@"txt"];
    wView.pm25LabelRight.text=self.weatherDic[@"pm25"];
    wView.pm10LabelRight.text=self.weatherDic[@"pm10"];
    wView.qltyLabelRight.text=self.weatherDic[@"qlty"];
    wView.humLabelRight.text=[NSString stringWithFormat:@"%@%@",self.weatherDic[@"hum"],@"%"];
    wView.dirLabelRight.text=[NSString stringWithFormat:@"%@ %@级",self.weatherDic[@"dir"],self.weatherDic[@"sc"]];
    wView.presLabelRight.text=[NSString stringWithFormat:@"%@ hPa",self.weatherDic[@"pres"]];
    wView.comfLabel.text=self.weatherDic[@"comf"];
    [wView.comfLabel  sizeToFit];
    _weatherView.alpha=0.9;
    
    _weatherView.backgroundColor=[UIColor blackColor];
    UITapGestureRecognizer * cancelTap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelTapAction:)];
    [_weatherView addGestureRecognizer:cancelTap];
    [self.tabBarController.view addSubview:_weatherView];
    
}
-(void)cancelTapAction:(UITapGestureRecognizer*)tap{
    [_weatherView removeFromSuperview];
}
-(void)update{
     [self.stepNumberCountingLabel countFrom:0 to:self.stepCount withDuration:3.0];
     [self.dakaCountingLabel countFrom:0 to: self.kcal withDuration:3.0];
     [self.timeCountingLabel countFrom:0 to:self.time withDuration:3.0];
     [self.gongliCountingLabel countFrom:0 to:self.kil withDuration:3.0];
    [self.chart removeFromSuperview];
    CGFloat  chartHeight=HEIGHT-113-100-(WIDTH-150)-40;
    self.chart = [[SNChart alloc] initWithFrame:CGRectMake(-10, HEIGHT-113-chartHeight, self.view.frame.size.width, chartHeight) withDataSource:self andChatStyle:SNChartStyleBar];
    self.chart.kYEqualPaths=5;
    self.chart.chartBarTheYAxisSpan=(chartHeight-50)/5;
    [self.chart showInView:self.view];
}
- (void)createLineProgressView{
    self.circleProgress = 0;
    self.circleChart = [[VAProgressCircle alloc] initWithFrame:CGRectMake(WIDTH/2-(WIDTH-150)/2, 130, WIDTH-150, WIDTH-150)];
    [self.circleChart setColor:[UIColor yellowColor] ];
    [self.circleChart setTransitionColor:[UIColor colorWithRed:0.89 green:0.22 blue:0.61 alpha:1.00]];
    self.circleChart.transitionType = VAProgressCircleColorTransitionTypeGradual;
    self.circleChart.delegate = self;
    self.randomTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(randomIncrement) userInfo:nil repeats:YES];
    [self.view addSubview:self.circleChart];
//今日步数
    self.stepNumberCountingLabel=[UICountingLabel new];
    self.stepNumberCountingLabel.textAlignment=NSTextAlignmentCenter;
    self.stepNumberCountingLabel.font=[UIFont systemFontOfSize:70*SCREENWIDTH];
    self.stepNumberCountingLabel.textColor=[UIColor colorWithRed:0.98 green:0.6 blue:0 alpha:1];
    [self.circleChart addSubview:self.stepNumberCountingLabel];
    self.stepNumberCountingLabel.format = @"%d";
    [self.stepNumberCountingLabel countFrom:0 to:self.stepCount withDuration:3.0];
    [self.stepNumberCountingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WIDTH, 80));
        make.centerY.mas_equalTo(self.circleChart);
    }];
    UILabel * stepNumberLabel=[UILabel new];
    stepNumberLabel.text=@"今日步数";
    stepNumberLabel.font=[UIFont systemFontOfSize:25*SCREENWIDTH];
    stepNumberLabel.textAlignment=NSTextAlignmentCenter;
    stepNumberLabel.textColor=[UIColor colorWithRed:0.32 green:0.32 blue:0.32 alpha:1];
    [self.circleChart addSubview:stepNumberLabel];
    [stepNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.stepNumberCountingLabel.mas_top).offset(0);
        make.size.mas_equalTo(CGSizeMake(WIDTH, 30));
    }];
}
//定时器
- (void)randomIncrement{
    int  stepCount;
    if (self.stepCount/100>=100) {
        stepCount=100-1;
    }else{
        stepCount=(int)self.stepCount/100-1;
    }
    int randomIncrement = self.circleProgress + arc4random_uniform(stepCount - self.circleProgress) / 3;
    if(self.circleProgress != randomIncrement && randomIncrement > self.circleProgress){
        self.circleProgress = randomIncrement;
        [self.circleChart setProgress:self.circleProgress];
    }else{
        self.circleProgress++;
        [self.circleChart setProgress:self.circleProgress];
    }
}
- (void)resetChart
{
    self.circleProgress = 0;
    
    if([self.randomTimer isValid])
    {
        [self.randomTimer invalidate];
    }
    
    [self.circleChart removeFromSuperview];
    self.circleChart = nil;
    
    [self createLineProgressView];
}

-(void)createSNchart{
    CGFloat  chartHeight=HEIGHT-113-100-(WIDTH-150)-40;
    self.chart = [[SNChart alloc] initWithFrame:CGRectMake(-10, HEIGHT-113-chartHeight, self.view.frame.size.width, chartHeight) withDataSource:self andChatStyle:SNChartStyleBar];
    self.chart.kYEqualPaths=5;
    self.chart.chartBarTheYAxisSpan=(chartHeight-50)/5;
    [self.chart showInView:self.view];
}

- (NSArray *)chatConfigYValue:(SNChart *)chart {
    if (!self.stepCountArr) {
    
    return @[@"0",@"0",@"0",@"0",@"0",@"0",@"100"];
    }
    return self.stepCountArr;
}
- (NSArray *)chatConfigXValue:(SNChart *)chart {
    return @[@"6-9",@"9-12",@"12-15",@"15-18",@"18-21",@"21-24"];
}
-(void)showCalendar:(UITapGestureRecognizer *)recognizer{
    __block UILabel * label=self.dateLabel;
    __block HealthCenterViewController *HCV = self;
    if (self.calendarPicker.pickerShow==NO) {
         self.calendarPicker = [SZCalendarPicker showOnView:self.view];
        self.calendarPicker.today = [NSDate date];
        self.calendarPicker.date = self.calendarPicker.today;
        self.calendarPicker.frame = CGRectMake(0, 0, self.view.frame.size.width, 352);
        self.calendarPicker.calendarBlock = ^(NSInteger day, NSInteger month, NSInteger year){
            label.text=[NSString stringWithFormat:@"%li月%li日",month,day];
            NSLog(@"%li-%li-%li", year,month,day);
            NSString * dateStr=[NSString stringWithFormat:@"%ld-%02ld-%02ld", year,month,day];
            [HCV createData:dateStr];
            [HCV resetChart];
           // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [HCV update];
        
          //   });
         
        };
        
    }else{
        [self.calendarPicker hide];
      
    }
}
#pragma mark -- 加号方法
-(void)add:(UIBarButtonItem *)button{
   // AddViewController *addVC=[[AddViewController alloc] init];
   // [self.navigationController pushViewController:addVC animated:YES];
    
    
    
}

-(void)createCalendar{
    //日历
    UIView * calendarVIew=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 120, 30)];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showCalendar:)];
    [calendarVIew addGestureRecognizer:tap];
    UIImageView * calendarImageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 28, 28)];
    calendarImageView.image=[UIImage imageNamed:@"iconfont-rili.png"];
    [calendarVIew addSubview:calendarImageView];
    NSDate *  senddate=[NSDate date];
    NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"MM月dd日"];
    NSString *  locationString=[dateformatter stringFromDate:senddate];
   self.dateLabel=[[UILabel alloc] initWithFrame:CGRectMake(30, 0, 90, 30)];
    self.dateLabel.text=locationString;
    [calendarVIew addSubview:self.dateLabel];
    self.navigationItem.titleView =calendarVIew;
}
-(void)createTopView{
    self.topView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 100)];
    [self.view addSubview:self.topView];
    
    //大卡
    UILabel * dakaLabel=[UILabel new];
    dakaLabel.text=@"大卡";
    dakaLabel.textAlignment=NSTextAlignmentCenter;
    dakaLabel.font=[UIFont systemFontOfSize:20];
    dakaLabel.textColor=[UIColor colorWithRed:0.32 green:0.32 blue:0.32 alpha:1];
    [self.topView addSubview:dakaLabel];
    [dakaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(self.topView.frame.size.width/3, self.topView.frame.size.height/2));
    }];
    self.dakaCountingLabel=[UICountingLabel new];
    self.dakaCountingLabel.textAlignment=NSTextAlignmentCenter;
    self.dakaCountingLabel.font=[UIFont systemFontOfSize:45];
    self.dakaCountingLabel.textColor=[UIColor colorWithRed:0.98 green:0.6 blue:0 alpha:1];
    [self.topView addSubview:self.dakaCountingLabel];
    self.dakaCountingLabel.format = @"%d";
    [self.dakaCountingLabel countFrom:0 to: self.kcal withDuration:3.0];
    [self.dakaCountingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(dakaLabel.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(self.topView.frame.size.width/3, self.topView.frame.size.height/2));
    }];
    
    //活跃时间
    UILabel * timeLabel=[UILabel new];
    timeLabel.text=@"活跃时间";
    timeLabel.textAlignment=NSTextAlignmentCenter;
    timeLabel.font=[UIFont systemFontOfSize:20];
    timeLabel.textColor=[UIColor colorWithRed:0.32 green:0.32 blue:0.32 alpha:1];
    [self.topView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(dakaLabel.mas_right).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.topView.frame.size.width/3, self.topView.frame.size.height/2));
    }];
    self.timeCountingLabel=[UICountingLabel new];
    self.timeCountingLabel.textAlignment=NSTextAlignmentCenter;
    self.timeCountingLabel.font=[UIFont systemFontOfSize:45];
    self.timeCountingLabel.textColor=[UIColor colorWithRed:0.98 green:0.6 blue:0 alpha:1];
    [self.topView addSubview:self.timeCountingLabel];
    self.timeCountingLabel.format =@"%dm";
    [self.timeCountingLabel countFrom:1 to:self.time withDuration:3.0];
    [self.timeCountingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(timeLabel.mas_bottom);
        make.left.mas_equalTo(self.dakaCountingLabel.mas_right);
        make.size.mas_equalTo(CGSizeMake(self.topView.frame.size.width/3, self.topView.frame.size.height/2));
    }];
    //公里数
    UILabel * gongliLabel=[UILabel new];
    gongliLabel.text=@"公里";
    gongliLabel.textAlignment=NSTextAlignmentCenter;
    gongliLabel.font=[UIFont systemFontOfSize:20];
    gongliLabel.textColor=[UIColor colorWithRed:0.32 green:0.32 blue:0.32 alpha:1];
    [self.topView addSubview:gongliLabel];
    //公里适配
    [gongliLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(timeLabel.mas_right).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.topView.frame.size.width/3, self.topView.frame.size.height/2));
    }];
    self.gongliCountingLabel=[UICountingLabel new];
    self.gongliCountingLabel.textAlignment=NSTextAlignmentCenter;
    self.gongliCountingLabel.font=[UIFont systemFontOfSize:45];
    self.gongliCountingLabel.textColor=[UIColor colorWithRed:0.98 green:0.6 blue:0 alpha:1];
    [self.topView addSubview:self.gongliCountingLabel];
    self.gongliCountingLabel.format = @"%.1f";
    [self.gongliCountingLabel countFrom:0 to:self.kil withDuration:3.0];
    //显示公里数适配
    [self.gongliCountingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(gongliLabel.mas_bottom);
        make.left.mas_equalTo(self.timeCountingLabel.mas_right);
        make.size.mas_equalTo(CGSizeMake(self.topView.frame.size.width/3, self.topView.frame.size.height/2));
    }];
}
-(void)createPhotoAndMap{
//    VMButtonCircleFun *toujiView = [[VMButtonCircleFun alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
//    toujiView.backgroundColor=[UIColor whiteColor];
//    [toujiView addCircleLayerWithType:VMMakeLocationTop];
//    toujiView.strokeColor = [UIColor orangeColor];
//    toujiView.center = CGPointMake(40, CGRectGetHeight(self.view.bounds)/2);
//    [toujiView setIconButton:[UIImage imageNamed:@"iconfont-zhuzhuangtu.png"] withType:VMMakeLocationTop withColor:nil];
//    [toujiView setLineWidthValue:5];
//    [self.view addSubview:toujiView];
//    [toujiView buildButton];
//    UITapGestureRecognizer *tapTouji=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTouji:)];
//    [toujiView addGestureRecognizer:tapTouji];

    
    
    VMButtonCircleFun *mapView = [[VMButtonCircleFun alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
    [mapView addCircleLayerWithType:VMMakeLocationBottom];
    mapView.strokeColor =[UIColor orangeColor];
    mapView.center = CGPointMake(WIDTH-40, CGRectGetHeight(self.view.bounds)/2);
    [mapView setIconButton:[UIImage imageNamed:@"iconfont-ditu.png"] withType:VMMakeLocationBottom withColor:nil];
    [mapView setLineWidthValue:5];
    [self.view addSubview:mapView];
    [mapView buildButton];
    UITapGestureRecognizer *tapMap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMap:)];
    [mapView addGestureRecognizer:tapMap];
}

#pragma mark --截图手势方法
-(void)tapTouji:(UITapGestureRecognizer *)tap{
   AddViewController *addVC=[[AddViewController alloc] init];
    [self presentViewController:addVC animated:YES completion:^{
        
    }];
    
    NSLog(@"截图");
    
}
-(void)tapMap:(UITapGestureRecognizer *)tap{
    WYWRunMapViewController * runMapVC=[[WYWRunMapViewController alloc] init];
    [self presentViewController:runMapVC animated:YES completion:^{
        
    }];
    NSLog(@"显示地图");
    
}

-(void)viewWillAppear:(BOOL)animated{
    
    NSLog(@"------");
    
    
    
}
- (void)progressCircle:(VAProgressCircle *)circle willAnimateToProgress:(int)progress{
    
}
- (void)progressCircle:(VAProgressCircle *)circle didAnimateToProgress:(int)progress{

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
